home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #4 / Amiga Plus CD - 2000 - No. 4.iso / Tools / Grafik / Misc / ImageEnginer / ARexx / Batch / Emboss_fast.ieb < prev    next >
Encoding:
Text File  |  1997-02-02  |  3.7 KB  |  145 lines

  1. /*
  2. ** $VER: Emboss_fast.ieb 1.11, IE Arexx script
  3. ** Image Engineer Batch Processing script
  4. ** Copyright © by Patrik M Nydensten
  5. ** 27/1 1997 Stockholm/Sweden
  6. **
  7. ** Emboss image using Composite/Subtract.
  8. */
  9.  
  10. options results
  11. signal on error
  12.  
  13. parse arg input command
  14. input = upper(strip(input))
  15. address 'IMAGEENGINEER'
  16.  
  17. select  /* Required batch script commands */
  18.   when input = 'INFO' then    return get_info()
  19.   when input = 'CONFIG' then  return get_config(command)
  20.   when input = 'PROCESS' then return process_image(command)
  21.   otherwise do
  22.     'REQUEST' '"Failure in call to batch script!"' '" Quit "'
  23.     return '<ERROR>'
  24.   end
  25. end
  26.  
  27. exit 0
  28.  
  29. /* Required "Get_info" procedure  ------------------------------------ */
  30. /* S = SECONDARY, A = ALPHA, 1 = Single file, 2 = Multiple files       */
  31.  
  32. get_info:
  33.   back = 'OK'
  34. return back
  35.  
  36. /* Required "Get_config" procedure  ---------------------------------- */
  37.  
  38. get_config:
  39.   parse arg '"'command'"'
  40.  
  41.   Xoff=2 ; Yoff=2 ; Boost=0
  42.  
  43.   if command ~= '' then parse var command Xoff Yoff '#'BoostCol Boost
  44.  
  45.   'IE_TO_FRONT'
  46.  
  47.   form = 'FORM "Emboss fast" " OK | Cancel "',
  48.   ' INTEGER,"X emboss",-16,16,'Xoff',SLIDER',
  49.   ' INTEGER,"Y emboss",-16,16,'Yoff',SLIDER'
  50.  
  51.   if command = '' then form = form||' CYCLE,"Edge colors:","Make them grey|Keep / Boost",0'
  52.  
  53.   form = form||' INTEGER,"Color boost",0,255,'Boost',SLIDER'
  54.  
  55.   form
  56.  
  57.   if command = '' then do
  58.     parse var result ok Xoff Yoff BoostCol Boost .
  59.     if ok = 0 then return '<ERROR>'
  60.   end
  61.   else do
  62.     parse var result ok Xoff Yoff Boost .
  63.     if ok = 0 then return '<ERROR>'
  64.     BoostCol = 'none'
  65.   end
  66.  
  67.   back = Xoff Yoff '#'BoostCol Boost
  68. return back
  69.  
  70. /* Required "Process_image" procedure  ------------------------------- */
  71.  
  72. process_image:
  73.   parse arg '"'src_image'"' '"'dst_image'"' '"'options'"'
  74.   parse var options Xoff Yoff '#'BoostCol Boost .
  75.  
  76.   if BoostCol=1 then 'OPEN' '"'src_image'"' '24'
  77.   else 'OPEN' '"'src_image'"' '8'
  78.   if (RC ~= 0) then do
  79.     'IE_TO_FRONT'
  80.     'REQUEST' '"Failed to load image:' d2c(10)||src_image'"' '" OK "'
  81.     return '<ERROR>'
  82.   end
  83.   else LoadImage = result
  84.  
  85.   'PROJECT_INFO' LoadImage 'WIDTH'    /* Get width of image */
  86.   IW = RESULT
  87.   'PROJECT_INFO' LoadImage 'HEIGHT'    /* Get height of image */
  88.   IH = RESULT
  89.  
  90.   if Xoff > IW then Xoff = IW
  91.   if Yoff > IH then Yoff = IH
  92.  
  93.   'MARK' LoadImage 'PRIMARY'
  94.   'MARK' LoadImage 'SECONDARY'
  95.  
  96.   'COMPOSITE' Xoff Yoff 'SUBTRACT'
  97.   OutputImage = result
  98.   'CLOSE' LoadImage
  99.  
  100.   if BoostCol = 1 then do  /* boost colors */
  101.     'SATURATION' OutputImage Boost
  102.     NewOutputImage = Result
  103.     'CLOSE' OutputImage
  104.     OutputImage = NewOutputImage
  105.   end
  106.   else if left(getclip('cfg_save_frmt'),4)~='ILBM' then do
  107.     'CONVERT_TO_COLOUR' OutputImage
  108.     TempImage = result
  109.     'CLOSE' OutputImage
  110.     OutputImage = TempImage
  111.   end
  112.  
  113.   if getclip('cfg_save_frmt')='' then setclip('cfg_save_frmt','ILBM CmpByteRun1')
  114.   'SAVE_DATA' OutputImage '"'dst_image'"' '"'getclip('cfg_save_frmt')'"'
  115.   if (RC ~= 0) then do
  116.     'IE_TO_FRONT'
  117.     'REQUEST' '"Failed to save image:' d2c(10)||dst_image'"' '" OK "'
  118.     return '<ERROR>'
  119.   end
  120.   'CLOSE' OutputImage
  121.  
  122.   back = 'OK'
  123. return back
  124.  
  125. /* Internal procedures  ---------------------------------------------- */
  126.  
  127. /*******************************************************************/
  128. /* This is where control goes when an error code is returned by IE */
  129. /* It puts up a message saying what happened and on which line     */
  130. /*******************************************************************/
  131.  
  132. error:
  133. if RC=5 then do
  134.     IE_TO_FRONT
  135.     LAST_ERROR
  136.     'REQUEST "'||RESULT||'"'
  137. end
  138. else do
  139.     IE_TO_FRONT
  140.     LAST_ERROR
  141.     'REQUEST "Error detected!!!'||D2C(10)||'Image Engineer error message is as follows'||D2C(10)||result||D2C(10)||'Script failed on line '||SIGL||'"' 'Doh!'
  142. end
  143.  
  144. return '<ERROR>'
  145.